import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WorkerForm, WorkerQuery, WorkerVO } from './types';

/**
 * 查询员工信息列表
 * @param query
 * @returns {*}
 */

export const listWorker = (query?: WorkerQuery): AxiosPromise<WorkerVO[]> => {
  return request({
    url: '/proj/worker/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询员工信息详细
 * @param workerId
 */
export const getWorker = (workerId: string | number): AxiosPromise<WorkerVO> => {
  return request({
    url: '/proj/worker/' + workerId,
    method: 'get'
  });
};

/**
 * 新增员工信息
 * @param data
 */
export const addWorker = (data: WorkerForm) => {
  return request({
    url: '/proj/worker',
    method: 'post',
    data: data
  });
};

/**
 * 修改员工信息
 * @param data
 */
export const updateWorker = (data: WorkerForm) => {
  return request({
    url: '/proj/worker',
    method: 'put',
    data: data
  });
};

/**
 * 删除员工信息
 * @param workerId
 */
export const delWorker = (workerId: string | number | Array<string | number>) => {
  return request({
    url: '/proj/worker/' + workerId,
    method: 'delete'
  });
};
